<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>一个多用户博客后台</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link rel="shortcut icon" href="favicon.ico">
    <link href="../public/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="../public/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="../public/css/animate.css" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="../public/js/plugins/editor/css/editormd.min.css" />
    <link href="../public/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="../public/css/plugins/switchery/switchery.css" rel="stylesheet">
    <link href="../public/js/plugins/datapicker-puls/bootstrap-datetimepicker.min.css" rel="stylesheet">
    <link href="../public/css/plugins/toastr/toastr.min.css" rel="stylesheet">

</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content">

        <div class="row">
            <div class="col-lg-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>编辑文章</h5>
                        <div class="ibox-tools">
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                            <a class="dropdown-toggle" data-toggle="dropdown" href="form_advanced.html#">
                                <i class="fa fa-wrench"></i>
                            </a>
                            <ul class="dropdown-menu dropdown-user">
                                <li><a href="form_advanced.html#">选项1</a>
                                </li>
                                <li><a href="form_advanced.html#">选项2</a>
                                </li>
                            </ul>
                            <a class="close-link">
                                <i class="fa fa-times"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content">

                        <form action="/admin/edit-acticle{{actile&&actile._id}}" method="POST" role="form"
                            class="row form-horizontal">
                            <div class="form-group">
                                <label class="col-sm-1 control-label">文章标题：</label>
                                <div class="col-sm-11">
                                    <input type="text" class="form-control" name="title"
                                        value="{{actile&&actile.title}}">

                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>

                            <div class="form-group">
                                <label class="col-sm-1 control-label">文章分类：</label>
                                <div class="col-sm-4">
                                    <select class="form-control" name="categoryId">
                                        {{each cate}}
                                        {{if ($value.id ==actile.categoryId)}}
                                        <option value="{{$value.id}}" selected>{{$value.name}}</option>
                                        {{else}}
                                        <option value="{{$value.id}}">{{$value.name}}</option>
                                        {{/if}}
                                        {{/each}}
                                    </select>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label">撰写作者：</label>
                                <div class="col-sm-4">
                                    <select class="form-control" name="authorId">
                                        {{each user}}
                                        {{if ($value.id ==actile.authorId)}}
                                        <option value={{$value.id}} selected>{{$value.name}}</option>
                                        {{else}}
                                        <option value={{$value.id}}>{{$value.name}}</option>
                                        {{/if}}
                                        {{/each}}
                                    </select>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label">发帖时间：</label>
                                <div class="col-sm-4">
                                    <input type="text" name="createAt" class="form-control form_datetime" readonly
                                        value="{{actile.createAt }}">
                                </div>
                            </div>

                            <div class="form-group">
                                    <label class="col-sm-1 control-label">缩略图：</label>
                                    <div class="col-sm-4" id="file-pretty">
                                        <input type="file" class="form-control" name="thumbnail">
                                    </div>
                                </div>
    

                            <div id="layout" class="editor">
                                <div id="test-editormd">
                                    <textarea name="content">{{actile&&actile.content}}</textarea>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label">文章标签：</label>
                                <div class="col-sm-11">
                                    <input type="text" class="form-control" name="tags" placeholder=" (逗号分割) 显示常用标签"
                                        value="{{taginfo}}">
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <div class="col-sm-4">
                                {{if (actile.state==1)}}
                                    <label class="control-label">不公开：</label>
                                    <input type="checkbox" name="state" class="js-switch_3" value="0"/> 
                                {{else}}
                                    <label class="control-label">公开：</label>
                                    <input type="checkbox" name="state" class="js-switch_3" value="1" />
                                {{/if}}
                                {{if actile.top}}   
                                ｜ <label class="control-label">取消置顶：</label>
                                <input type="checkbox" name="top" class="js-switch_3" value="false"/>　｜
                                {{else}}
                                ｜ <label class="control-label">置顶：</label>
                                <input type="checkbox" name="top" class="js-switch_3" value="true"/>　｜  
                                {{/if}}
                                {{if actile.good}}
                                <label class="control-label">取消精华：</label> 
                                <input type="checkbox" name="good" class="js-switch_3" value="false" />
                                {{else}}
                                <label class="control-label">精华：</label> 
                                <input type="checkbox" name="good" class="js-switch_3" value="true" />
                                {{/if}}



                                </div>
                                <div class="col-sm-6">
                                    <button class="btn btn-primary save" type="submit">保存内容</button>
                                </div>


                        </form>




                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-lg-12">
                <div class="ibox float-e-margins">

                    <div class="ibox-content">
                        <div data-provide="markdown-editable">
                            <h2>editormd简介</h2>
                            <p>editormd是一款优秀的markdown编辑器，提供了实用的API，利用插件进行扩展。<code>你可以单击这段文字试试</code>
                            </p>
                        </div>
                        <p class="alert alert-success alert-dismissable m-t">
                            更多示例请访问：<a href="https://www.jianshu.com/p/8c1b2b39deb0">markdown语法整理</a>
                            <br>GitHub：
                            <a href="http://www.markdown.cn">markdown教程</a>
                        </p>
                    </div>
                </div>
            </div>
        </div>
    </div>
    </div>

    <!-- 全局js -->
    <script src="../public/js/jquery.min.js?v=2.1.4"></script>
    <script src="../public/js/bootstrap.min.js?v=3.3.6"></script>

    <!-- 自定义js -->
    <script src="../public/js/content.js?v=1.0.0"></script>


    <!-- 日期选择插件 -->
    <script src="../public/js/plugins/datapicker-puls/bootstrap-datetimepicker.min.js"></script>
    <script src="../public/js/plugins/datapicker-puls/bootstrap-datetimepicker.zh-CN.js"></script>
    <!-- 文件上传插件 -->
    <script src="../public/js/plugins/prettyfile/bootstrap-prettyfile.js"></script>
    <!--状态切换插件-->
    <script src="../public/js/plugins/switchery/switchery.js"></script>
    <!-- TOST -->
    <script src="../public/js/plugins/toastr/toastr.min.js"></script>
    <script>
        $(document).ready(function () {
            toastr.options = {
                "closeButton": true,
                "debug": false,
                "progressBar": true,
                "positionClass": "toast-top-right",
                "onclick": null,
                "showDuration": "400",
                "hideDuration": "800",
                "timeOut": "2000",
                "extendedTimeOut": "500",
                "showEasing": "swing",
                "hideEasing": "linear",
                "showMethod": "fadeIn",
                "hideMethod": "fadeOut"
            }
            {{if toastinfo}}
            toastr.{{ toastinfo.type }} ('{{toastinfo.info}}')
            {{/if}}
            //文件上传
            $('#file-pretty input[type="file"]').prettyFile();



            //swith
            var elem_1 = document.querySelectorAll('.js-switch_3')[0]
            var elem_2 = document.querySelectorAll('.js-switch_3')[1]
            var elem_3 = document.querySelectorAll('.js-switch_3')[2]
            var mySwitch = new Switchery(elem_1, { color: '#1AB394', size: 'small' });
            new Switchery(elem_2, { color: '#1AB394', size: 'small' });
            new Switchery(elem_3, { color: '#1AB394', size: 'small' });
            //日期时间选择
            $(".form_datetime").datetimepicker({
                format: "yyyy-mm-dd hh:ii",
                language: "zh-CN",
                autoclose: true,
                todayBtn: true,
                pickerPosition: "bottom-left"
            });
            //toast
            $('.save').on('click', function () {
                toastr.info("文章正在保存")
            })

        })
    </script>

    <!-- simditor -->
    <script src="../public/js/plugins/editor/editormd.min.js"></script>
    <script src="../public/js/plugins/editor/plugins/image-dialog-qiniu/image-dialog-qiniu.js"></script>
    <script type="text/javascript">
        var testEditor;

        $(function () {

            testEditor = editormd("test-editormd", {
                width: "100%",
                height: 740,
                path: './../public/js/plugins/editor/lib/',
                codeFold: true,
                //syncScrolling : false,
                saveHTMLToTextarea: true,    // 保存 HTML 到 Textarea
                searchReplace: true,
                //watch : false,                // 关闭实时预览
                htmlDecode: "style,script,iframe|on*",            // 开启 HTML 标签解析，为了安全性，默认不开启    
                //toolbar  : false,             //关闭工具栏
                //previewCodeHighlight : false, // 关闭预览 HTML 的代码块高亮，默认开启
                emoji: true,
                taskList: true,
                tocm: true,         // Using [TOCM]
                tex: true,                   // 开启科学公式TeX语言支持，默认关闭
                flowChart: true,             // 开启流程图支持，默认关闭
                sequenceDiagram: true,       // 开启时序/序列图支持，默认关闭,
                //dialogLockScreen : false,   // 设置弹出层对话框不锁屏，全局通用，默认为true
                //dialogShowMask : false,     // 设置弹出层对话框显示透明遮罩层，全局通用，默认为true
                //dialogDraggable : false,    // 设置弹出层对话框不可拖动，全局通用，默认为true
                //dialogMaskOpacity : 0.4,    // 设置透明遮罩层的透明度，全局通用，默认值为0.1
                //dialogMaskBgColor : "#000", // 设置透明遮罩层的背景颜色，全局通用，默认为#fff
                imageUpload: true,
                imageFormats: ["jpg", "jpeg", "gif", "png", "bmp", "webp"],
                // imageUploadURL: "/upload/article",
                toolbarIcons: function () {
                    return [
                        "undo", "redo", "bold", "del", "italic", "hr", "|",
                        "h1", "h2", "h3", "h4", "h5", "h6", "list-ul", "list-ol", "|",
                        "link", "reference-link", "qiniu", "table", "code", "code-block", "datetime", "|",
                        "goto-line", "preview", "watch", "|",
                        "fullscreen", "clear", "search"];
                    },
                //配置七牛上传插件
                toolbarIconsClass: {
                qiniu: "fa-cloud-upload"
                },
                toolbarHandlers: {
                qiniu: function (cm, icon, cursor, selection) {
                    this.imageDialogQiniu();
                }
                },
                qiniuTokenUrl: "/upload/getQiNiuToken",          //本地服务器获取七牛token的url
                qiniuPublishUrl: "http://cdn.liqunonline.cn/" ,   //远程七牛服务器个人发布地址
                onload: function () {
                    console.log('onload', this);
                    //this.fullscreen();
                    //this.unwatch();
                    //this.watch().fullscreen();

                    //this.setMarkdown("#PHP");
                    //this.width("100%");
                    //this.height(480);
                    //this.resize("100%", 640);
                }
            });

        });
    </script>


</body>

</html>